package com.bw.controller;

import com.bw.bean.*;
import com.bw.service.VoService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
public class VoController {
    @Autowired
    VoService voService;
    @RequestMapping("list1")
    public Map list1(){
        List list = new ArrayList<>();
        List<Vo1> list1 = voService.list1();
        list.add("章节名称");
        list.add("播放次数");
        list.add("播放时长");
        list.add("观看人数");
        list.add("人均观看时长");
        return SugarUtil.getTablePlayData(list,list1);
    }

    @RequestMapping("list2")
    public Map list2(){
        List<Vo2> list2 = voService.list2();
        return SugarUtil.getPieData(list2);
    }

    @RequestMapping("list3")
    public Map list3(){
        List<Vo2> list3 = voService.list3();
        return SugarUtil.getMapData(list3);
    }

    @RequestMapping("list4")
    public Map list4(){
        List<Vo2> list4 = voService.list4();
        return SugarUtil.getLineData(list4);
    }
    @RequestMapping("list5")
    public Map list5(){
        List list = new ArrayList<>();
        List<Vo3> list5 = voService.list5();
        list.add("来源名称");
        list.add("订单总额");
        list.add("下单用户总数");
        list.add("订单总数");
        return SugarUtil.getTablePlayData(list,list5);
    }

    @RequestMapping("list6")
    public Map list6(){
        List list = new ArrayList<>();
        List<Vo4> list6 = voService.list6();
        list.add("课程名称");
        list.add("考试人次");
        list.add("平均分");
        list.add("平均用时");
        return SugarUtil.getTablePlayData(list,list6);
    }

    @RequestMapping("list7")
    public Map list7(){
        List list = new ArrayList<>();
        List<Vo5> list7 = voService.list7();
        list.add("课程名称");
        list.add("平均评分");
        list.add("评价人数");
        list.add("好评人数");
        list.add("好评率");
        return SugarUtil.getTablePlayData(list,list7);
    }

    @RequestMapping("list8")
    public Map list8(){
        Integer list8 = voService.list8();
        return SugarUtil.getFlipNumberData(list8);
    }
}
